package com.oig.sys.auth.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupEdit;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

@Data
@Schema(description = "部门信息参数")
public class DepartmentDto {

    /**
     * 必填项没有按 @validation group来生成，需要在具体方法上加 swagger的 requestBody注解处理，麻烦先全部改为非必填项
     * requiredMode = Schema.RequiredMode.NOT_REQUIRED
     */
    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误,id不能为空", groups= GroupEdit.class)
    private Integer id;

    @Schema(description = "所属租户id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误,所属租户id不能为空", groups={GroupAdd.class,GroupEdit.class})
    private Integer tenantId;
    @Schema(description = "租户编码")
    private String tenantCode;
    @Schema(description = "所属租户", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误,所属租户不能为空", groups={GroupAdd.class,GroupEdit.class})
    private String tenantName;

    @Schema(description = "上级部门id,新增不填时，默认为0，编辑必填", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误,上级部门id不能为空", groups={GroupEdit.class})
    private Integer parentId ;
    @Schema(description = "上级部门名称,不填时，默认为空")
//    @NotEmpty(message = "参数错误,上级部门名称不能为空", groups={GroupEdit.class})
    private String parentName ;

    @Schema(description = "部门编码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误,部门编码不能为空", groups={GroupAdd.class,GroupEdit.class})
    private String departCode;

    @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误,部门名称不能为空", groups={GroupAdd.class,GroupEdit.class})
    private String departName;

    @Schema(description = "部门管理人id")
    private Integer masterId;

    @Schema(description = "部门管理人")
    private String masterName;

    @Schema(description = "部门成立时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date establishTime;

    @Schema(description = "部门人员,配置部门人员，只需传人员id")
    List<UserMiniDto> userList ;

}
